import requests
from bs4 import BeautifulSoup
# # from requests.api import head

# url = 'http://47.103.13.124:8001/sign'
# header={
#     'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0'
# }
# cookie={
#     'session':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMDFXg.Scw77GHoivgwl97HiRjozDllbJ8'
# }

# t = requests.get(url,headers=header,cookies=cookie)
# print(t.text)

import requests

cookies = {
    'session':'.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMDFXg.Scw77GHoivgwl97HiRjozDllbJ8; auth=672FPMNK775683YRX1623246180',
    # 'session': '.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMDorQ.zWGKV8Qf0bkHy1zr8ZIpU6BgIVs',
    'sign':'baae522ab301bf0f9ff54d19d7e266a3'#32位
}

headers = {
    'Connection': 'keep-alive',
    'Accept': 'application/json, text/plain, */*',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
    'Accept-Language': 'zh-CN,zh;q=0.9',
}

# params = (
#     ('actions', '16356^'),
#     ('tim', '1623327259^'),
#     ('randstr', 'GGJQQ^'),
#     ('sign', 'baae522ab301bf0f9ff54d19d7e266a3'),
# )

response = requests.get('http://47.103.13.124:8001/sign', headers=headers,cookies=cookies, verify=False)
print(response.text)
#NB. Original query string below. It seems impossible to parse and
#reproduce query strings 100% accurately so the one below is given
#in case the reproduced version is not "correct".
# response = requests.get('http://47.103.13.124:8001/movies_sign_ajax?actions=16356^&tim=1623327259^&randstr=GGJQQ^&sign=baae522ab301bf0f9ff54d19d7e266a3', headers=headers, cookies=cookies, verify=False)





# import hashlib

# md5 = hashlib.md5()
# md5.update('how to use md5 in python hashlib?'.encode('utf-8'))
# print(md5.hexdigest())

# md5 = hashlib.md5()
# md5.update('how to use md5 in '.encode('utf-8'))
# md5.update('python hashlib?'.encode('utf-8'))
# print(md5.hexdigest())

'''
curl "http://47.103.13.124:8001/movies_sign_ajax?actions=16356^&tim=1623327259^&randstr=GGJQQ^&sign=baae522ab301bf0f9ff54d19d7e266a3" ^
  -H "Connection: keep-alive" ^
  -H "Accept: application/json, text/plain, */*" ^
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" ^
  -H "Accept-Language: zh-CN,zh;q=0.9" ^
  -H "Cookie: session=.eJyrViotTi1SsqpWyiyOT0zJzcxTsjLQUcrJTwexSopKU3WUcvOTMnNSlayUDM3gQEkHrDE-M0XJyhjCzkvMBSmKKTVNMjMDkiamFkq1tQDfeR3n.YMDorQ.zWGKV8Qf0bkHy1zr8ZIpU6BgIVs" ^
  --compressed ^
  --insecure
'''

# import requests

# cookies = {
#     'session': '.eJwli0sKgCAYBu_yrV3kAzLPEojlTwg-QHMV3j2szTCLmQe9UYV5EJp1PoUMwxliuabdtRNDKkeIBAMuhdiUlmLRYN9og4dZf88uzWjvivQ5KRTGeAHfrR4z.YLRe-w.-tswl5jBYKxiU181bUcW60hzDeM',
#     'auth': '872QBRKC424283OBW1622437318',
# }

# headers = {
#     'Connection': 'keep-alive',
#     'Pragma': 'no-cache',
#     'Cache-Control': 'no-cache',
#     'Upgrade-Insecure-Requests': '1',
#     'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36',
#     'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
#     'Sec-Fetch-Site': 'same-origin',
#     'Sec-Fetch-Mode': 'navigate',
#     'Sec-Fetch-User': '?1',
#     'Sec-Fetch-Dest': 'document',
#     'Referer': 'http://127.0.0.1:8888/cookies',
#     'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
# }

# response = requests.get('http://127.0.0.1:8888/movies_cookies', headers=headers, cookies=cookies)
# print(response.text)

























